<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Cp1251">
<title>Edit tractor</title>
</head>
<body>
    <?php
    	session_start();
	    $db_connect = mysqli_connect("localhost", "root", "root", "tractor");
	    $producer_id = $_GET['producer_id'];
	    
	    echo "<form method=\"post\" action=\"edit_tractor.php?producer_id=$producer_id\">";
	    $query = "SELECT model, price
	    			FROM producer WHERE producer_id='$producer_id'";
	     
	    $result = mysqli_query($db_connect, $query);
	    $producer_row = mysqli_fetch_assoc($result);
	     
	    echo "<p>Name:<input name=\"model\" value=\"".$producer_row['model']."\"/></p>\n";
	    echo "<p>Phone:<input name=\"price\" value=\"".$producer_row['price'] ."\"/></p>\n";
	    echo "<input type=\"submit\" value=\"Edit\" name=\"edit_producer\"/>";
	    echo "</form>";
	    if(isset($_POST['edit_producer']))
	    {
	    	$model = $_POST['model'];
	    	$price = $_POST['price'];
	    	$update = "Update producer
	    	set model = '$model', price = '$price'
	    	where producer_id = '$producer_id'";
	    	 
	    	mysqli_query($db_connect, $update);
	    	 
	    	mysqli_close($db_connect);
	    	header("Location: main.php");
	    }
	?>
</body>
</html>